package com.itheima.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.common.PageBean;
import com.itheima.dto.ClazzQueryDto;
import com.itheima.mapper.ClazzMapper;
import com.itheima.pojo.Clazz;
import com.itheima.service.ClazzService;
import com.itheima.vo.ClazzVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ClazzServiceImpl implements ClazzService {
    @Autowired
    ClazzMapper clazzMapper;

    //分页查询班级
    @Override
    public PageBean pageQuery(ClazzQueryDto dto) {
        PageHelper.startPage(dto.getPage(), dto.getPageSize());
        Page<ClazzVo> page = clazzMapper.query(dto);
        long total = page.getTotal();
        List<ClazzVo> result = page.getResult();
        PageBean pageBean = new PageBean(total, result);
        return pageBean;
    }
}
